﻿using System;
using System.Collections.Generic;
using System.Text;
using Volo.Abp;

namespace mozhi.smarterp.Finance.Banks
{
    public class BankType : AggregateRootBase<Guid>
    {
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { private set; get; }

        private BankType() { }

        public BankType(Guid id , string name)
        {
            Id = id;
            Name = name;
            Activated = true;
            Validate();
        }

        private void Validate()
        {
            if (Name.IsNullOrEmpty())
                throw new UserFriendlyException("名称不能为空");
        }

        public void Change(string name , bool activated)
        {
            this.Name = name ?? Name;
            this.Activated = activated;

            Validate();
        }
    }
}
